import java.awt.Canvas;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Graphics;

import javax.swing.JPanel;

import World.World;


public class MyCanvas extends Canvas {
	private static final long serialVersionUID = 1L;

	Color LiveColor = Color.white;
	Color DeadColor = Color.black;
	Font textFont = new Font("Times New Roman", Font.BOLD, 24);
	Graphics temp = null;
	//boolean init = false;
	
	public MyCanvas(int width, int height)
	{
		this.isLightweight();
		setVisible(true);
		setSize(width, height);
		
	}
	
	public void paint (Graphics g){
		//g = temp;
		int height = World.environGrid.length; //Main.myWorld.grid.length;
		int width = World.environGrid[0].length;// Main.myWorld.grid[0].length;
		int cellSize = World.cellSize; //Main.myWorld.cellSize;

		for (int i=0; i<World.population.length; i++)
		{
			System.out.println(i+": "+World.population[i].getX() + "," + World.population[i].getY());
			g.setColor(World.population[i].getColor());
			g.fillRect((int)World.population[i].getX()*cellSize+(int)(0.25*cellSize), (int)World.population[i].getY()*cellSize+(int)(0.25 * cellSize), 1+(int)(0.5*cellSize),1+(int)(0.5*cellSize));
		}
	}
	
	public void Alert(String txt){
		temp = this.getGraphics();
		this.getGraphics().setColor(Color.black);
		this.getGraphics().setFont(textFont);
		this.getGraphics().drawString(txt, 5, 29);
	}
	

}
